菜单切换
FACESOHO知行者
心灵
记录
远方
赞赏工具
源代码:
点击运行
保存
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script> </head> <body> <div id="app"> <span>{{message}}</span><hr> <span>{{currentTarget}}</span><hr> <button v-on:click="say('hi',$event)">say hi</button> </div> <script> new Vue({ el:'#app', data:{message:"至乐无如读书,至要莫如教子。",currentTarget:"You clicked a "}, methods:{ say:function(message,e){ this.message = message + this.message; this.currentTarget = this.currentTarget + e.currentTarget.tagName; } } }) </script> </body> </html>
运行结果